﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OOAD_Project_Engine.Application.Services;
using OOAD_Project_Engine.Foundation.Interfaces;
using OOAD_Project_Engine.Domain.Factories;

namespace OOAD_Project_Editor.Domain.ManageSceneActions
{
    [Action(ActionType = EActionType.AddEntityComponent)]
    class AddEntityComponentAction : ManageSceneAction
    {
        IEntity entity;
        Type componentType;
        object[] parameters = new object[0];
        IEntityComponent component;
        public AddEntityComponentAction(ISceneService scene, IEntity entity, Type componentType, params object[] param)
            : base(scene)
        {
            this.componentType = componentType;
            this.entity = entity;
            if (param != null)
                this.parameters = param;
        }

        public override void DoAction()
        {
            component = EntityComponentFactory.CreateComponent(componentType, parameters);
            entity.Add(component);
        }

    }
}
